package com.example.wangfanwangluo.wangfanboss;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.WindowManager;

import com.flyco.tablayout.CommonTabLayout;
import com.flyco.tablayout.listener.CustomTabEntity;

import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {
    private ArrayList<Fragment> mFragments = new ArrayList<>();
    private String[] mTitles = {"工作", "我的"};
    private int[] mIconUnselectIds = {R.drawable.work_1, R.drawable.mine_1 };
    private int[] mIconSelectIds = {R.drawable.work_2, R.drawable.mine_2};
    private ArrayList<CustomTabEntity> mTabEntities = new ArrayList<>();
    private View mDecorView;
    private ViewPager mViewPager;
    private CommonTabLayout mTabLayout;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        ActionBar actionbar = getSupportActionBar();
        if (actionbar != null){
            actionbar.hide();
        }
        mFragments.add(WorkFragment.getInstance("工作" ));
        mFragments.add(MineFragment.getInstance("我的" ));
        for (int i = 0; i < mTitles.length; i++) {
            mTabEntities.add(new TabEntity(mTitles[i], mIconSelectIds[i], mIconUnselectIds[i]));
        }
        mDecorView = getWindow().getDecorView();
        /** with Fragments */
        mTabLayout = ViewFindUtils.find(mDecorView, R.id.tl);
        mTabLayout.setTabData(mTabEntities, this, R.id.fl_change, mFragments);

    }
}
